<?php
//-------------------------------------------------------------------------------------------------------
    require_once($config['app_dir'] . '/includes/number.class.php');
    require_once($config['app_dir'] . '/includes/template.class.php');
	require_once($config['app_dir'] . '/includes/db.class.php');
    //---------------------------------------------------------------------------------------------------
    class objMAPPerformance {
            protected $_data = array();
            protected $_sql_querys = array();
            public $SystemID;
			public $MAPID;

        public function __construct() {
              $this->_sqls();
			  $this->db = objDataBase::GetInstance();//new objDataBase();
        }//constructor


        public function GetPerformanceData() {

          	$dbdata = $this->db->handler->GetAll($this->_sql_querys['monthly_performance'],array($this->MAPID));
			foreach ($dbdata as $perfMonth){
					$year = $perfMonth['Year'];
					$month = $perfMonth['Month'];
					$this->_data[$year][$month] = $perfMonth['Result'];
			
			}
			
          	//var_dump($this->_data);
			return $this->_data;

        }

		public function GetAvgPerformanceData() {

          	$dbdata = $this->db->handler->GetRow($this->_sql_querys['avg_performance'],array($this->MAPID));
			
          	//var_dump($dbdata);
			return $dbdata;

        } 		



        protected function BuildDecimal() {
            for($i=0; $i<count($this->_data); $i++) {
                /*
                $ti = 0;
                $td = 0.1;
                while( $this->_data[$i]['PipSize']<$td ) { $ti++;  $td*=0.1; }
                $this->_data[$i]['decimal'] = $ti;
                */
                $this->_data[$i]['decimal'] = NumberConvert::decimal($this->_data[$i]['PipSize']);
            }//for
        } //buildDecimal

        protected function _sqls() {
            $this->_sql_querys['monthly_performance'] =
                           "SELECT * ".
                           " FROM fa_map_performance".
                           " WHERE MAPID=?".
                           " ORDER BY Year,Month";
			$this->_sql_querys['avg_performance'] =
                           "SELECT * ".
                           " FROM fa_map".
                           " WHERE ID=?";
        } //_sqls

    } //class objLastRateServer


?>
